package com.fengling.mapper;

import com.fengling.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

@Mapper

public interface EmpMapper {
    @Delete("delete from tb_emp where id=#{id}")
    public void delete(Integer id);

    @Options(useGeneratedKeys = true, keyProperty = "id")    //两个属性  其中use代表我们要获取到返回回来的主键值
    //          keyP代表返回回来的主键往哪个属性封装

    @Insert("insert into tb_emp( username, name, gender, image, job, entrydate, dept_id, create_time, update_time) value (#{username},#{name},#{gender},#{img},#{job},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    public void insert(Emp emp);

    @Update("update tb_emp set username=#{username},name=#{name},gender=#{gender},image=#{img},job=#{job}" +
            ",entrydate=#{entryDate},dept_id=#{deptId},update_time=#{updateTime} where id=#{id}")
    public void update(Emp emp);


    @Select("select *from tb_emp where id=#{id}")
    public Emp select(Integer id);

    @Select("SELECT * from tb_emp where name like concat('%',#{name},'%')and gender=#{gender} and entrydate" +
            "    between #{begin} and #{end} order by update_time desc ")
    public List<Emp> select2(String name, Short gender, LocalDate begin, LocalDate end);


    public List<Emp> select3(String name, Short gender, LocalDate begin, LocalDate end);
    public List<Emp> select3S(String name, Short gender, LocalDate begin, LocalDate end);

    public void update2(Emp emp);
    public void deleteIds(List<Integer> ids);

}
